<template>
	<view class="container">
		<view class="top">
			<view class="search-box">
				<headerSearch bgColor="#F6F6F6" placeholder="可通过名称、手机号搜索"></headerSearch>
			</view>
			<view class="nav-2">
				<view class="dropDownBox">
					<DropBox :dropTabList="dropList" navWidth="auto" :isLeftBorder="false" rightSlotWidth="224">
						<view slot="right" class="right">
							<button>导入</button>
						</view>
						
						<view slot="nl" class="nl-con">
							<view class="radio-list">
								<view class="radio-box" :class="nl_idx==i?'select':''" v-for="(item,i) in nlList" :key="i">
									{{item.text}}
								</view>
							</view>
							<view class="inpit-box">
								<input type="text" placeholder="单行输入" placeholder-class="pla-class" />
								<text></text>
								<input type="text" placeholder="单行输入" placeholder-class="pla-class" />
							</view>
							<view class="nl-btn">
								<button>重置</button>
								<button>确定</button>
							</view>
						</view>
						<view slot="qy" class="qy-con">
							<view class="select-box">
								<view class="cell">
									<view class="item one-row" 
									@click="selectCity(0,i)" 
									:class="cityValue[0]==i ? 'select':''" 
									v-for="(item,i) in cityList" :key="item.value">
										{{item.name}}
									</view>
								</view>
								<view class="cell-2">
									<view class="item" 
									@click="selectCity(1,i)" 
									:class="cityValue[1]==i ? 'select':''" 
									v-for="(item,i) in cityList[cityValue[0]]&&cityList[cityValue[0]].children ? cityList[cityValue[0]].children : []" :key="item.value">
										{{item.name}}
									</view>
								</view>
								<view class="cell-2 cell-3">
									<view class="item" 
									@click="selectCity(2,i)" 
									:class="cityIds.includes(item.value) ? 'select':''" 
									v-for="
									(item,i) in 
									cityList[cityValue[0]].children&&cityList[cityValue[0]].children[cityValue[1]]&&cityList[cityValue[0]].children[cityValue[1]].children 
									? cityList[cityValue[0]].children[cityValue[1]].children : []" :key="item.value">
										{{item.name}}
										<image v-if="cityIds.includes(item.value)" :src="$img_path('/pagesMine/14.png')" mode="widthFix"></image>
										<!-- <image v-else :src="$img_path('/pagesMine/15.png')" mode="widthFix"></image> -->
									</view>
								</view>
							</view>
							<view class="nl-btn">
								<button>重置</button>
								<button>确定</button>
							</view>
						</view>
					</DropBox>
				</view>
			</view>
		</view>
		
		<view class="list">
			<view class="item" v-for="item in 5">
				<image v-if="false" :src="$img_path('pagesMine/14.png')" mode="widthFix"></image>
				<image v-else :src="$img_path('pagesMine/15.png')" mode="widthFix"></image>
				<view class="con-box">
					<view class="name">
						<text>王五六</text>    <text>（男 | 65岁 | 12345678910）</text>
					</view>
					<view class="jb">
						疾病：<text>感冒</text>
					</view>
					<view class="address">
						住址：<text>河南省郑州市中原区详细地址详细地址详细地址</text>
					</view>
				</view>
			</view>
		</view>
		
		<view class="bottom-btn">
			<view class="b-box">
				<view class="all-chack">
					<image v-if="false" :src="$img_path('pagesMine/14.png')" mode="widthFix"></image>
					<image v-else :src="$img_path('pagesMine/15.png')" mode="widthFix"></image>
					<text>全选</text>
				</view>
				<button @click="submitOrder">下单</button>
			</view>
		</view>
	</view>
</template>

<script>
	import popupBox from '@/components/popup/popup.vue'
	import headerSearch from '@/components/header-search/header-search.vue'
	import DropBox from '../../components/drop/drop.vue';
	export default {
		components:{
			headerSearch,
			popupBox,
			DropBox
		},
		data() {
			return {
				dropList:[
					{
						props:'nl',
						text:'年龄',
						slot:true
					},
					{
						props:'sex',
						text:'性别',
						slot:false,
						list:[
							{
								text:'全部',
								value:''
							},
							{
								text:'男',
								value:'1'
							},
							{
								text:'女',
								value:'2'
							}
						]
					},
					{
						props:'qy',
						text:'区域',
						slot:true
					}
				],
				nlList:[
					{
						text:'55岁以上',
						value:1
					},
					{
						text:'55~60岁',
						value:2
					},
					{
						text:'60~65岁',
						value:3
					},
					{
						text:'65~70岁',
						value:4
					},
					{
						text:'70~75岁',
						value:5
					},
					{
						text:'75~80岁',
						value:6
					},
					{
						text:'80岁以上',
						value:7
					},
				],
				nl_idx:null,
				cityList:[
					{
						name:'全国',
						value:'1',
						children:[
							
						]
					},{
						name:'河南',
						value:'2',
						children:[
							{
								name:'全河南',
								value:'7',
								children:[
									
								]
							},{
								name:'郑州',
								value:'8',
								children:[
									{
										name:'全郑州',
										value:'9',
									},
									{
										name:'中原区',
										value:'10',
									},{
										name:'二七区',
										value:'11',
									},{
										name:'金水区',
										value:'12',
									},{
										name:'管城回族区',
										value:'13',
									},
								]
							},
						]
					},{
						name:'北京',
						value:'3',
					},{
						name:'山东',
						value:'4',
					},{
						name:'河北',
						value:'5',
					},{
						name:'山西',
						value:'6',
					}
				],
				cityValue:[0],
				cityIds:[]
			};
		},
		methods:{
			selectCity(i,data){
				if(i==0){
					if(data!=this.cityValue[0]){
						this.cityValue=[data,0,0]
					}
				}else if(i==1){
					if(data!=this.cityValue[1]){
						this.cityValue=[this.cityValue[0],data,0]
					}
				}else{
					// if(data!=this.cityValue[2]){
					// 	this.cityValue=[this.cityValue[0],this.cityValue[1],data]
						
					// }else{
						
					// }
					this.$set(this.cityValue,i,data)
						let val = this.cityList[this.cityValue[0]].children[this.cityValue[1]].children
					if(data==0){
						if(this.cityIds.includes(val)){
							let idx = this.cityIds.indexOf(val[data].value)
							this.cityIds=[]
						}else{
							this.cityIds=[val[data].value]
						}
					}else{
						if(this.cityIds.indexOf(val[0].value)>=0){
							this.cityIds.splice(this.cityIds.indexOf(val[0].value),1)
						}
						// let val = this.cityList[this.cityValue[0]].children[this.cityValue[1]].children[data].value
						if(this.cityIds.includes(val[data].value)){
							let idx = this.cityIds.indexOf(val[data].value)
							this.cityIds.splice(idx,1)
						}else{
							this.cityIds.push(val[data].value)
						}
					}
				}
				
			},
			
			submitOrder(){
				uni.navigateTo({
					url:`/pagesRegion/majorClients/optService`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.container{
	.top{
		position: sticky;
		top: 0;
		left: 0;
		right: 0;
		z-index: 3;
		background-color: #FFFFFF;
		padding-bottom: 20rpx;
		.search-box{
			position: relative;
			z-index: 5;
			padding: 14rpx 22rpx 20rpx;
			background-color: #FFFFFF;
			header-search{
				height: 84rpx;
			}
		}
		.nav-2{
			background-color: #FFFFFF;
			// display: flex;
			// justify-content: space-between;
			// padding: 22rpx 22rpx 26rpx;
			// box-sizing: border-box;
			// .dropDownBox{
			// 	width: calc(100% - 224rpx);
			// }
			.right{
				// width: 224rpx;
				background-color: #FFFFFF;
				position: relative;
				// z-index: 5;
				button{
					width: 132rpx;
					height: 64rpx;
					background: #E72A2A;
					border-radius: 12rpx;
					font-weight: 400;
					font-size: 32rpx;
					color: #FFFFFF;
					line-height: 64rpx;
				}
			}
		}
	}
	.nl-con{
		.radio-list{
			display: flex;
			align-items: center;
			flex-wrap: wrap;
			.radio-box{
				width: calc(25% - 16rpx);
				height: 68rpx;
				background: #EEEEEE;
				border-radius: 8rpx;
				margin-top: 20rpx;
				&:not(:nth-child(4n)){
					margin-right: 20rpx;
				}
				font-weight: 400;
				font-size: 28rpx;
				color: #5B5B5B;
				line-height: 68rpx;
				text-align: center;
				&.select{
					background-color: #E72A2A;
					color: #FFFFFF;
				}
			}
		}
		.inpit-box{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 40rpx;
			input{
				width: calc(50% - 39rpx);
				height: 68rpx;
				background: #FFFFFF;
				border-radius: 8rpx;
				border: 2rpx solid #B4B4B4;
				padding: 0 20rpx;
				box-sizing: border-box;
				/deep/ .pla-class{
					font-weight: 400;
					font-size: 28rpx;
					color: #B4B4B4;
					line-height: 40rpx;
				}
			}
			&>text{
				position: relative;
				display: block;
				width: 46rpx;
				height: 68rpx;
				&::before{
					content: '';
					display: inline-block;
					width: 46rpx;
					height: 2rpx;
					background-color: #000000;
					position: absolute;
					left: 0;
					top: 50%;
					transform: translateY(-50%);
				}
			}
		}
		.nl-btn{
			display: flex;
			justify-content: space-between;
			margin-top: 40rpx;
			button{
				&:nth-child(1){
					width: 198rpx;
					height: 96rpx;
					background: #FFFFFF;
					border-radius: 80rpx;
					border: 2rpx solid #FF4A4A;
					font-weight: bold;
					font-size: 36rpx;
					color: #FF4A4A;
					line-height: 96rpx;
				}
				&:nth-child(2){
					width: calc(100% - 218rpx);
					height: 96rpx;
					background: linear-gradient( 135deg, #FFA233 0%, #FB4C4C 100%);
					border-radius: 80rpx;
					font-weight: bold;
					font-size: 36rpx;
					color: #FFFFFF;
					line-height: 96rpx;
				}
			}
		}
	}
	
	.qy-con{
		.select-box{
			display: flex;
			margin-top: 20rpx;
			.cell{
				width: 184rpx;
				overflow-y: auto;
				height: 340rpx;
				.item{
					background: #EEEEEE;
					width: 100%;
					height: 84rpx;
					font-weight: 400;
					font-size: 32rpx;
					color: #5B5B5B;
					line-height: 84rpx;
					text-align: center;
					padding: 0 20rpx;
					box-sizing: border-box;
					&.select{
						background-color: #FFFFFF;
						position: relative;
						font-weight: bold;
						color: #000000;
						&:before{
							position: absolute;
							content: '';
							width: 8rpx;
							height: 84rpx;
							background: #E72A2A;
							border-radius: 4rpx;
							left: 0;
							top: 0;
						}
					}
				}
			}
			.cell-2{
				width: calc(50% - 112rpx);
				overflow-y: auto;
				height: 340rpx;
				&.cell-3{
					width: calc(50% - 72rpx);
					padding: 0 40rpx 0 20rpx;
				}
				.item{
					width: 100%;
					height: 84rpx;
					font-weight: 400;
					font-size: 32rpx;
					color: #5B5B5B;
					line-height: 84rpx;
					text-align: center;
					padding: 0 20rpx;
					box-sizing: border-box;
					&.select{
						font-weight: bold;
						color: #000000;
					}
					
					position: relative;
					&>image{
						width: 40rpx;
						height: 40rpx;
						position: absolute;
						right: 0;
						top: 50%;
						transform: translateY(-50%);
					}
				}
			}
		}
		.nl-btn{
			display: flex;
			justify-content: space-between;
			margin-top: 40rpx;
			button{
				&:nth-child(1){
					width: 198rpx;
					height: 96rpx;
					background: #FFFFFF;
					border-radius: 80rpx;
					border: 2rpx solid #FF4A4A;
					font-weight: bold;
					font-size: 36rpx;
					color: #FF4A4A;
					line-height: 96rpx;
				}
				&:nth-child(2){
					width: calc(100% - 218rpx);
					height: 96rpx;
					background: linear-gradient( 135deg, #FFA233 0%, #FB4C4C 100%);
					border-radius: 80rpx;
					font-weight: bold;
					font-size: 36rpx;
					color: #FFFFFF;
					line-height: 96rpx;
				}
			}
		}
	}

	.list{
		padding: 0 22rpx;
		box-sizing: border-box;
		.item{
			background: #FFFFFF;
			border-radius: 20rpx;
			padding: 26rpx 24rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			margin-top: 20rpx;
			image{
				width: 36rpx;
				height: 36rpx;
			}
			.con-box{
				padding-left: 20rpx;
				width: calc(100% - 36rpx);
				&>.name{
					font-weight: bold;
					font-size: 32rpx;
					color: #000000;
					line-height: 44rpx;
					text:first-child{
						margin-right: 40rpx;
					}
				}
				.jb,.address{
					margin-top: 24rpx;
					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
					line-height: 40rpx;
					text{
						font-weight: bold;
						color: #000000;
					}
				}
			}
		}
	}
	
	
	.bottom-btn{
		width: 100%;
		height: calc(constant(safe-area-inset-bottom) + 148rpx);
		height: calc(env(safe-area-inset-bottom) + 148rpx);
		
		.b-box{
			position: fixed;
			bottom: 0;
			left: 0;
			right: 0;
			padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
			padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #FFFFFF;
			.all-chack{
				display: flex;
				align-items: center;
				padding-left: 22rpx;
				image{
					width: 36rpx;
					height: 36rpx;
				}
				text{
					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
					line-height: 40rpx;
					margin-left: 12rpx;
				}
			}
			button{
				width: 224rpx;
				height: 108rpx;
				background: #E72A2A;
				font-weight: 400;
				font-size: 32rpx;
				color: #FFFFFF;
				line-height: 108rpx;
				border-radius: 0;
			}
		}
	}
}
</style>
